import type { IRentCopyOrderDTO, IRentMachineOrderInfoList } from "@/types/rentMachineManage/rentMachineOrderInfo";

/* 复制订单 */
function useCopyOrder(fn?: () => void) {
  const copyOrderVisible = ref(false);
  const copyOrderForm = ref<IRentCopyOrderDTO>({
    id: 0,
    mobile: ""
  });

  /* 打开复制订单模态框 */
  function handleCopyOrder(row: IRentMachineOrderInfoList) {
    copyOrderForm.value.id = row.id;
    copyOrderForm.value.mobile = row.mobile;
    copyOrderVisible.value = true;
  }
  /* 复制订单成功回调 */
  function handleCopyOrderSuccess() {
    copyOrderVisible.value = false;
    if (fn) {
      fn();
    }
  }

  return {
    copyOrderVisible,
    copyOrderForm,
    handleCopyOrder,
    handleCopyOrderSuccess
  };
}

export default useCopyOrder;
